#pragma once
#include"exceptii.h"


template <class t>
class List_Statistic
{
	t*obj,*last;
	int index;
public:
	List_Statistic()
	{
		this->obj=NULL;
		index=0;
	}
	~List_Statistic()
	{
		delete obj;
	}

	void add(t&obj,int file)
	{
		t*aux=new t;
		index++;
		aux=&obj;

		if (file==1)
			aux->aparitii_fis1++;
		else if(file==2)
			aux->aparitii_fis2++;


		if(this->obj==NULL)
		{
			this->obj=last=aux;
			this->obj->next=NULL;

			


		}
		else
		{
			this->last->next=aux;
			aux->next=NULL;
			this->last=this->last->next;
		
		}

	
	}

	t&operator[](int index)
{
		t*aux=obj;
		int x=0;

		while(x!=index)
		{
			aux=aux->next;
			x++;
		
		}

		return *aux;
	}

	
	//o metoda de stergere recursiva......
	int remove_list(t&obj_rem)
	{
			if(obj_rem)
			{
				remove_list(obj_rem->next);

				delete obj_rem;
				obj_rem=NULL;
			
			}
	}
	//daca a gasit cuvantul doar creste numarul de aparitii
	int verify_for(t&obj, int file)
	{
		
		
		
			t*aux=this->obj;

			while(aux)
			{
				if (strcmp(aux->cuv,obj.cuv)==0)
				{
					if(file==1)
					aux->aparitii_fis1++;
					else if(file==2)
					aux->aparitii_fis2++;

					return 1;
				
				}
					aux=aux->next;

			}
		
			return 0;

	
	}

	int get_index()
	{
		return index;
	}

};